|
|
|
|
|
|
|
Figure 10.4
A depth 11 tree with DTHETA = 90 degrees. |
|
|
|
|
|
|
|
|
By adjusting the parameters in program BinTree2, you can create trees that look very different, but they are all symmetrical. You need to look at only a few real trees to realize they are not symmetrical. Branches are rarely straight for more than a few feet; they are bent by wind and gravity, and they do not always divide into two smaller branches. By adding a little randomness to your programs, you can make trees that look much more natural. These trees still look like computer-generated drawings, but a little randomness gives them a pleasing asymmetry. |
|
|
|
|
|
|
|
|
There are several tree parameters you can adjust randomly. You can vary the lengths and angles of the branches slightly to produce a much less symmetric tree that looks more natural. You can also vary the number of branches that appear when a branch splits. |
|
|
|
|
|
|
|
|
With a little extra work, you can make the branches bend slightly. Instead of drawing to the end of each branch in a single step, add to the branch a little bit at a time. Each time you add a piece to the branch, add a small random amount to the angle in which the branch is growing. Figure 10.5 shows a depth seven tree with a variable number of bending branches of different lengths. |
|
|
|
|
|
|
|
|
The following code recursively draws a tree with randomized branch length, angle, and number of branches at each split. If the thickness parameter is greater than zero, the routine uses that value as the line's thickness. It then passes a smaller value into the recursive subroutine calls, making branches grow thinner as the tree progresses. |
|
|
|
|
|